#include <cmath>
#include <iostream>
using namespace std;

int main() {
  int a[7];
  int ans = 0;

  // 输入6种尺寸的蛋糕数量
  for (int i = 1; i <= 6; i++) {
    cin >> a[i];
  }

  // 处理6x6和5x5的蛋糕
  ans += a[6] + a[5];
  a[1] = max(0, a[1] - 11 * a[5]);

  // 处理4x4的蛋糕
  ans += a[4];
  a[2] = max(0, a[2] - 5 * a[4]);

  // 处理3x3的蛋糕
  ans += (a[3] + 3) / 4;
  int remaining_3x3 = a[3] % 4;
  if (remaining_3x3 > 0) {
    int space_2x2 = 7 - 2 * remaining_3x3;
    a[2] = max(0, a[2] - space_2x2);
    a[1] = max(0, a[1] - (8 - remaining_3x3));
  }

  // 处理2x2的蛋糕
  if (a[2] > 0) {
    ans += (a[2] + 8) / 9;
    a[1] = max(0, a[1] - (36 - (a[2] % 9) * 4));
  }

  // 处理1x1的蛋糕
  if (a[1] > 0) {
    ans += (a[1] + 35) / 36;
  }

  cout << ans << endl;
  return 0;
}